package com.hundsun.yr.universal.p2p.ui.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;

import com.hundsun.yr.universal.library.eventbus.EventCenter;
import com.hundsun.yr.universal.library.netstatus.NetUtils.NetType;
import com.hundsun.yr.universal.library.utils.RegularUtils;
import com.hundsun.yr.universal.library.widget.HSButton;
import com.hundsun.yr.universal.library.widget.HSEditText;
import com.hundsun.mobile.zwgt.R;
import com.hundsun.yr.universal.p2p.datahandler.RegisterValidateHandler;
import com.hundsun.yr.universal.p2p.ui.activity.base.BaseActivity;


/**
 * 注册  - 手机号录入
 *
 * @author tonglj
 */
public class RegisterInputPhoneActivity extends BaseActivity implements OnClickListener {
    private HSEditText et_phone;
    private HSButton btn_next;

    @Override
    protected boolean isApplyKitKatTranslucency() {
        return true;
    }

    @Override
    protected void getBundleExtras(Bundle extras) {

    }

    @Override
    protected int getContentViewLayoutID() {
        return R.layout.act_register_step1_setphone;
    }

    @Override
    protected void onEveComming(EventCenter eventCenter) {

    }

    @Override
    protected boolean isBindEventBusHere() {
        return false;
    }

    @Override
    protected View getLoadingTargetView() {
        return null;
    }

    @Override
    protected void initViewsAndEvents() {
        findView();
        setToolbarTitle(R.string.regiester_space);
        btn_next.setOnClickListener(this);
        mDataHandler = new RegisterValidateHandler(mContext);
    }

    private void findView() {
        et_phone = findView(R.id.register_et_phone);
        btn_next = findView(R.id.btn_register_next);
    }

    @Override
    protected void onNetworkConnected(NetType type) {

    }

    @Override
    protected void onNetworkDisConnected() {

    }

    @Override
    protected boolean isApplyStatusBarTranslucency() {
        return true;
    }

    @Override
    protected boolean toggleOverridePendingTransition() {
        return false;
    }

    @Override
    protected TransitionMode getOverridePendingTransitionMode() {
        return null;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_register_next:
                final String phonetext = et_phone.getPhone();
                if (TextUtils.isEmpty(phonetext)) {
                    showToast(R.string.toast_checkphone_empty);
                } else if (RegularUtils.isPhoneNum(phonetext)) {
//                    mDataHandler.interactive(mDataHandler, R.string.method_sendSms, phonetext);
                    //先跳转到第二个页面再说

                } else {
                    showToast(R.string.error_phone_number);
                }
                break;

            default:
                break;
        }
    }

}
